package neu.soft.service.impl;

import neu.soft.entity.OperationWarehouse;
import neu.soft.service.BaseInfoQueryService;
import neu.soft.service.WarehouseService;
import neu.soft.vo.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@Service("MAX_INVENTORY_QUERY")
public class MaxInventoryQueryServiceImpl implements BaseInfoQueryService {

    @Autowired
    WarehouseService warehouseService;

    @Override
    public ResultBean queryInfo(Map<String, Object> map) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {

        OperationWarehouse warehouse = warehouseService.findById(1);
        int num = (int) map.get("num");
        if (num <= warehouse.getMaxInventory()) {
            return ResultBean.success("true");
        }
        return ResultBean.error(500, "false");
    }
}
